package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TUserRole;
import com.ruoyi.system.service.ITUserRoleService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 【请填写功能名称】Controller
 * 
 * @author ruoyi
 * @date 2022-04-06
 */
@RestController
@RequestMapping("/system/userRole")
public class TUserRoleController extends BaseController
{
    @Autowired
    private ITUserRoleService tUserRoleService;

    /**
     * 查询【请填写功能名称】列表
     */
    @GetMapping("/list")
    public TableDataInfo list(TUserRole tUserRole)
    {
        startPage();
        List<TUserRole> list = tUserRoleService.selectTUserRoleList(tUserRole);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response, TUserRole tUserRole)
    {
        List<TUserRole> list = tUserRoleService.selectTUserRoleList(tUserRole);
        ExcelUtil<TUserRole> util = new ExcelUtil<TUserRole>(TUserRole.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    @GetMapping(value = "/{userId}")
    public AjaxResult getInfo(@PathVariable("userId") Long userId)
    {
        return AjaxResult.success(tUserRoleService.selectTUserRoleByUserId(userId));
    }

    /**
     * 新增【请填写功能名称】
     */
    @PostMapping
    public AjaxResult add(@RequestBody TUserRole tUserRole)
    {
        return toAjax(tUserRoleService.insertTUserRole(tUserRole));
    }

    /**
     * 修改【请填写功能名称】
     */
    @PutMapping
    public AjaxResult edit(@RequestBody TUserRole tUserRole)
    {
        return toAjax(tUserRoleService.updateTUserRole(tUserRole));
    }

    /**
     * 删除【请填写功能名称】
     */
	@DeleteMapping("/{userIds}")
    public AjaxResult remove(@PathVariable Long[] userIds)
    {
        return toAjax(tUserRoleService.deleteTUserRoleByUserIds(userIds));
    }
}
